<template>
    <view class="level-description">
        <!-- 卡片标题 -->
        <view class="card-header">
            <text class="card-title">🏆 等级成就</text>
            <text class="card-desc">您的学习等级与进度</text>
        </view>
        
        <!-- 当前等级展示 -->
        <view class="current-level-display">
            <view class="level-badge-wrapper">
                <view class="level-badge" :style="{ background: currentLevelInfo.color }">
                    <view class="badge-glow" :style="{ background: currentLevelInfo.color }"></view>
                    <text class="level-icon">{{ currentLevelInfo.icon }}</text>
                </view>
            </view>
            
            <view class="level-details">
                <view class="level-info">
                    <text class="level-name">{{ currentLevelInfo.name }}</text>
                    <text class="level-score">{{ userStats.averageScore }} 分</text>
                </view>
                
                <view class="progress-container">
                    <view class="progress-bar">
                        <view class="progress-fill" :style="{ 
                            width: `${currentLevelProgress}%`,
                            background: currentLevelInfo.color
                        }">
                            <view class="progress-shine"></view>
                        </view>
                    </view>
                    <text class="progress-text">{{ currentLevelProgress.toFixed(0) }}%</text>
                </view>
                
                <view class="next-level-hint" v-if="nextLevelInfo">
                    <text class="hint-text">
                        再得 <text class="required-points">{{ nextLevelRequiredScore }}</text> 分升至 
                        <text class="next-level">{{ nextLevelInfo.name }}</text>
                    </text>
                </view>
                <view class="max-level-hint" v-else>
                    <text class="max-text">🎉 已达最高等级</text>
                </view>
            </view>
        </view>
            

        
        <!-- 等级列表展开按钮 -->
        <view class="expand-toggle" @click="toggleLevelCard">
            <text class="toggle-text">查看等级体系</text>
            <view class="toggle-arrow" :class="{ 'expanded': showLevelCard }">
                <text class="arrow">›</text>
            </view>
        </view>
        
        <!-- 等级体系列表 -->
        <view v-if="showLevelCard" class="levels-list">
            <view 
                class="level-item" 
                v-for="(level, index) in levelInfoList" 
                :key="level.name"
                :class="{ 'active': isCurrentLevel(index), 'completed': isLevelCompleted(index) }"
                :style="{ background: level.color }"
            >
                <view class="item-badge">
                    <text class="item-icon">{{ getLevelIcon(index) }}</text>
                </view>
                
                <view class="item-content">
                    <view class="item-header">
                        <text class="item-name">{{ level.name }}</text>
                        <text class="item-range">{{ level.scoreRange }}</text>
                    </view>
                    
                    <view class="item-progress">
                        <view class="mini-progress">
                            <view class="mini-fill" :style="{ 
                                width: getLevelProgressWidth(index),
                                background: 'rgba(255, 255, 255, 0.8)'
                            }"></view>
                        </view>
                        
                        <view class="item-status">
                            <text v-if="isCurrentLevel(index)" class="status-current">当前</text>
                            <text v-else-if="isLevelCompleted(index)" class="status-completed">✓</text>
                            <text v-else class="status-locked">🔒</text>
                        </view>
                    </view>
                </view>
                
                <!-- 渐变遮罩层，增强视觉效果 -->
                <view class="gradient-overlay"></view>
            </view>
        </view>
    </view>
</template>

<script setup lang="ts">
import { ref, onMounted, computed } from 'vue';
import { LEVEL_CONFIGS } from '@/types';
import { getThemeStyles } from '@/stores/theme';

/**
 * 组件属性定义
 */
interface Props {
    userStats?: {
        averageScore: number;
    };
}

const props = withDefaults(defineProps<Props>(), {
    userStats: () => ({ averageScore: 75 })
});

/**
 * 等级说明卡片显示状态
 */
const showLevelCard = ref(false);

/**
 * 级别说明列表数据
 */
const levelInfoList = ref<Array<{
    name: string;
    color: string;
    scoreRange: string;
}>>([]);

/**
 * 用户统计数据（使用props或默认值）
 */
const userStats = computed(() => props.userStats);

/**
 * 切换等级说明卡片显示状态
 */
const toggleLevelCard = () => {
    showLevelCard.value = !showLevelCard.value;
};

/**
 * 获取当前主题样式
 */
const themeStyles = computed(() => getThemeStyles());

/**
 * 获取等级图标
 */
const getLevelIcon = (index: number): string => {
    const icons = ['🥉', '🥈', '🥇', '💎', '👑'];
    return icons[index] || '⭐';
};

/**
 * 根据分数获取当前等级信息
 */
const getCurrentLevel = (score: number) => {
    const levels = Object.keys(LEVEL_CONFIGS).map(key => parseInt(key)).sort((a, b) => a - b);
    
    for (let i = levels.length - 1; i >= 0; i--) {
        const levelKey = levels[i];
        const config = LEVEL_CONFIGS[levelKey];
        if (score >= config.minScore) {
            return {
                key: levelKey,
                config: config,
                icon: getLevelIcon(i)
            };
        }
    }
    
    // 如果没有匹配到任何等级，返回最低等级
    const lowestLevel = levels[0];
    return {
        key: lowestLevel,
        config: LEVEL_CONFIGS[lowestLevel],
        icon: getLevelIcon(0)
    };
};

/**
 * 当前等级信息
 */
const currentLevelInfo = computed(() => {
    const currentLevel = getCurrentLevel(userStats.value.averageScore);
    return {
        name: currentLevel.config.name,
        color: currentLevel.config.color,
        icon: currentLevel.icon,
        minScore: currentLevel.config.minScore,
        maxScore: currentLevel.config.maxScore
    };
});

/**
 * 下一等级信息
 */
const nextLevelInfo = computed(() => {
    const levels = Object.keys(LEVEL_CONFIGS).map(key => parseInt(key)).sort((a, b) => a - b);
    const currentLevel = getCurrentLevel(userStats.value.averageScore);
    const currentIndex = levels.indexOf(currentLevel.key);
    
    if (currentIndex < levels.length - 1) {
        const nextLevelKey = levels[currentIndex + 1];
        const nextConfig = LEVEL_CONFIGS[nextLevelKey];
        return {
            name: nextConfig.name,
            color: nextConfig.color,
            minScore: nextConfig.minScore
        };
    }
    
    return null; // 已经是最高等级
});

/**
 * 当前等级进度百分比
 */
const currentLevelProgress = computed(() => {
    const current = currentLevelInfo.value;
    const score = userStats.value.averageScore;
    
    if (!current.maxScore) {
        // 最高等级，显示100%
        return 100;
    }
    
    const progress = ((score - current.minScore) / (current.maxScore - current.minScore)) * 100;
    return Math.min(Math.max(progress, 0), 100);
});

/**
 * 距离下一等级还需要的分数
 */
const nextLevelRequiredScore = computed(() => {
    if (!nextLevelInfo.value) return 0;
    return Math.max(0, nextLevelInfo.value.minScore - userStats.value.averageScore);
});

/**
 * 生成级别说明列表
 * @description 根据级别配置生成供UI显示的级别说明列表数据
 */
const generateLevelInfoList = () => {
    levelInfoList.value = Object.keys(LEVEL_CONFIGS)
        .map((key: string) => {
            const config = LEVEL_CONFIGS[parseInt(key)];
            return {
                name: config.name,
                color: config.color,
                scoreRange: config.maxScore
                    ? `${config.minScore}-${config.maxScore}分`
                    : `${config.minScore}分及以上`
            };
        });
};

/**
 * 判断是否为当前等级
 */
const isCurrentLevel = (index: number): boolean => {
    const currentLevel = getCurrentLevel(userStats.value.averageScore);
    const levels = Object.keys(LEVEL_CONFIGS).map(key => parseInt(key)).sort((a, b) => a - b);
    const currentIndex = levels.indexOf(currentLevel.key);
    return index === currentIndex;
};

/**
 * 获取等级进度宽度
 */
const getLevelProgressWidth = (index: number): string => {
    const currentLevel = getCurrentLevel(userStats.value.averageScore);
    const levels = Object.keys(LEVEL_CONFIGS).map(key => parseInt(key)).sort((a, b) => a - b);
    const currentIndex = levels.indexOf(currentLevel.key);
    
    if (index < currentIndex) {
        return '100%'; // 已完成的等级
    } else if (index === currentIndex) {
        return `${currentLevelProgress.value}%`; // 当前等级的进度
    } else {
        return '0%'; // 未达到的等级
    }
};

/**
 * 判断等级是否已完成
 */
const isLevelCompleted = (index: number): boolean => {
    const currentLevel = getCurrentLevel(userStats.value.averageScore);
    const levels = Object.keys(LEVEL_CONFIGS).map(key => parseInt(key)).sort((a, b) => a - b);
    const currentIndex = levels.indexOf(currentLevel.key);
    return index < currentIndex;
};

/**
 * 组件初始化
 */
onMounted(() => {
    generateLevelInfoList();
});
</script>

<style lang="scss" scoped>
.level-description {
    width: 100%;
}

/* 卡片标题 */
.card-header {
    margin-bottom: 24rpx;
}

.card-title {
    font-size: 32rpx;
    font-weight: 700;
    color: v-bind('getThemeStyles().textPrimary');
    display: block;
    margin-bottom: 6rpx;
}

.card-desc {
    font-size: 24rpx;
    color: v-bind('getThemeStyles().textSecondary');
    display: block;
}

/* 当前等级展示 */
.current-level-display {
    display: flex;
    align-items: center;
    gap: 20rpx;
    padding: 20rpx;
    background: v-bind('getThemeStyles().bgSecondary');
    border-radius: 16rpx;
    border: 1rpx solid v-bind('getThemeStyles().borderLight');
    margin-bottom: 20rpx;
}

.level-badge-wrapper {
    flex-shrink: 0;
}

.level-badge {
    width: 80rpx;
    height: 80rpx;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: 0 6rpx 20rpx rgba(0, 0, 0, 0.15);
}

.badge-glow {
    position: absolute;
    top: -10rpx;
    left: -10rpx;
    right: -10rpx;
    bottom: -10rpx;
    border-radius: 50%;
    opacity: 0.4;
    filter: blur(10rpx);
    animation: pulse 2s ease-in-out infinite;
}

.level-icon {
    font-size: 36rpx;
    position: relative;
    z-index: 2;
    filter: drop-shadow(0 2rpx 4rpx rgba(0, 0, 0, 0.3));
}

.level-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12rpx;
}

.level-info {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.level-name {
    font-size: 28rpx;
    font-weight: 700;
    color: v-bind('getThemeStyles().textPrimary');
}

.level-score {
    font-size: 24rpx;
    font-weight: 600;
    color: v-bind('currentLevelInfo.color');
}

.progress-container {
    display: flex;
    align-items: center;
    gap: 12rpx;
}

.progress-bar {
    flex: 1;
    height: 8rpx;
    background: v-bind('getThemeStyles().bgTertiary');
    border-radius: 4rpx;
    overflow: hidden;
    position: relative;
}

.progress-fill {
    height: 100%;
    border-radius: 4rpx;
    transition: width 1.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.progress-shine {
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.5), transparent);
    animation: shine 2.5s ease-in-out infinite;
}

.progress-text {
    font-size: 20rpx;
    font-weight: 600;
    color: v-bind('getThemeStyles().textSecondary');
    min-width: 48rpx;
    text-align: right;
}

.next-level-hint,
.max-level-hint {
    text-align: center;
}

.hint-text,
.max-text {
    font-size: 22rpx;
    color: v-bind('getThemeStyles().textSecondary');
    line-height: 1.4;
}

.required-points {
    font-weight: 700;
    color: v-bind('currentLevelInfo.color');
}

.next-level {
    font-weight: 700;
    color: v-bind('getThemeStyles().primaryColor');
}

.max-text {
    color: v-bind('getThemeStyles().primaryColor');
    font-weight: 600;
}

/* 展开切换按钮 */
.expand-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16rpx 20rpx;
    background: v-bind('getThemeStyles().bgTertiary');
    border-radius: 12rpx;
    border: 1rpx solid v-bind('getThemeStyles().borderLight');
    margin-bottom: 16rpx;
    transition: all 0.3s ease;
    cursor: pointer;
    
    &:active {
        transform: scale(0.98);
        background: v-bind('getThemeStyles().bgSecondary');
    }
}

.toggle-text {
    font-size: 26rpx;
    font-weight: 600;
    color: v-bind('getThemeStyles().textPrimary');
}

.toggle-arrow {
    width: 32rpx;
    height: 32rpx;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
    
    &.expanded {
        transform: rotate(90deg);
    }
}

.arrow {
    font-size: 24rpx;
    color: v-bind('getThemeStyles().textSecondary');
    font-weight: 600;
}

/* 等级展示区域 */
.level-showcase {
    display: flex;
    align-items: center;
    gap: 32rpx;
    margin-bottom: 32rpx;
    padding: 24rpx;
    background: v-bind('getThemeStyles().bgSecondary');
    border-radius: 20rpx;
    border: 1rpx solid v-bind('getThemeStyles().borderLight');
}

.level-badge-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16rpx;
}

.level-badge {
    width: 100rpx;
    height: 100rpx;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: 0 8rpx 32rpx rgba(0, 0, 0, 0.15);
    
    &::before {
        content: '';
        position: absolute;
        top: -4rpx;
        left: -4rpx;
        right: -4rpx;
        bottom: -4rpx;
        border-radius: 50%;
        background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.3), transparent);
        animation: rotate 3s linear infinite;
    }
}

.badge-glow {
    position: absolute;
    top: -20rpx;
    left: -20rpx;
    right: -20rpx;
    bottom: -20rpx;
    border-radius: 50%;
    opacity: 0.3;
    filter: blur(20rpx);
    animation: pulse 2s ease-in-out infinite;
}

.level-icon {
    font-size: 48rpx;
    position: relative;
    z-index: 2;
    filter: drop-shadow(0 2rpx 8rpx rgba(0, 0, 0, 0.3));
}

.level-ring {
    position: absolute;
    top: -8rpx;
    left: -8rpx;
    right: -8rpx;
    bottom: -8rpx;
    border: 2rpx solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
}

.level-name {
    font-size: 28rpx;
    font-weight: 700;
    color: v-bind('getThemeStyles().textPrimary');
    text-align: center;
}

.level-stats {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 24rpx;
}

.stat-item {
    flex: 1;
    text-align: center;
}

.stat-value {
    font-size: 40rpx;
    font-weight: 800;
    color: v-bind('getThemeStyles().textPrimary');
    display: block;
    margin-bottom: 8rpx;
    background: v-bind('getThemeStyles().primaryGradient');
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-label {
    font-size: 22rpx;
    color: v-bind('getThemeStyles().textSecondary');
    font-weight: 500;
    display: block;
}

.stat-divider {
    width: 2rpx;
    height: 60rpx;
    background: v-bind('getThemeStyles().borderLight');
    border-radius: 1rpx;
}

/* 进度区域 */
.progress-section {
    padding: 24rpx;
    background: v-bind('getThemeStyles().bgTertiary');
    border-radius: 16rpx;
    border: 1rpx solid v-bind('getThemeStyles().borderLight');
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16rpx;
}

.progress-title {
    font-size: 26rpx;
    font-weight: 600;
    color: v-bind('getThemeStyles().textPrimary');
}

.progress-percentage {
    font-size: 24rpx;
    font-weight: 700;
    color: v-bind('currentLevelInfo.color');
}

.progress-track {
    height: 12rpx;
    background: v-bind('getThemeStyles().bgSecondary');
    border-radius: 6rpx;
    overflow: hidden;
    margin-bottom: 16rpx;
    position: relative;
}

.progress-fill {
    height: 100%;
    border-radius: 6rpx;
    position: relative;
    transition: width 1.5s cubic-bezier(0.4, 0, 0.2, 1);
    
    &::after {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
        animation: shimmer 2s infinite;
    }
}

.progress-shine {
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.6), transparent);
    animation: shine 3s ease-in-out infinite;
}

.next-level-info,
.max-level-info {
    text-align: center;
}

.next-level-text,
.max-level-text {
    font-size: 24rpx;
    color: v-bind('getThemeStyles().textSecondary');
    line-height: 1.5;
}

.next-level-name {
    font-weight: 700;
    color: v-bind('getThemeStyles().primaryColor');
}

.required-score {
    font-weight: 700;
    color: v-bind('currentLevelInfo.color');
}

.max-level-text {
    color: v-bind('getThemeStyles().primaryColor');
    font-weight: 600;
}

/* 展开按钮 */
.expand-button {
    display: flex;
    align-items: center;
    gap: 16rpx;
    padding: 20rpx 24rpx;
    background: v-bind('getThemeStyles().bgSecondary');
    border-radius: 16rpx;
    border: 1rpx solid v-bind('getThemeStyles().borderLight');
    transition: all 0.3s ease;
    cursor: pointer;
    
    &:active {
        transform: scale(0.98);
        background: v-bind('getThemeStyles().bgTertiary');
    }
}

.expand-icon {
    font-size: 24rpx;
    width: 40rpx;
    height: 40rpx;
    display: flex;
    align-items: center;
    justify-content: center;
    background: v-bind('getThemeStyles().primaryGradient');
    border-radius: 10rpx;
    box-shadow: v-bind('getThemeStyles().shadowSm');
}

.expand-text {
    flex: 1;
    font-size: 28rpx;
    font-weight: 600;
    color: v-bind('getThemeStyles().textPrimary');
}

.expand-arrow {
    width: 32rpx;
    height: 32rpx;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
    
    &.rotated {
        transform: rotate(180deg);
    }
}

.arrow-icon {
    font-size: 20rpx;
    color: v-bind('getThemeStyles().textSecondary');
}

/* 等级列表 */
.levels-list {
    display: flex;
    flex-direction: column;
    gap: 12rpx;
    animation: slideDown 0.3s ease-out;
}

.level-item {
    display: flex;
    align-items: center;
    gap: 16rpx;
    padding: 16rpx;
    background: v-bind('getThemeStyles().bgSecondary');
    border-radius: 12rpx;
    border: 1rpx solid v-bind('getThemeStyles().borderLight');
    transition: all 0.3s ease;
    position: relative;
    
    &.active {
        border-color: v-bind('getThemeStyles().primaryColor');
        background: v-bind('getThemeStyles().bgTertiary');
        box-shadow: v-bind('getThemeStyles().shadowSm');
        
        &::before {
            content: '';
            position: absolute;
            left: 0;
            top: 0;
            bottom: 0;
            width: 4rpx;
            background: v-bind('getThemeStyles().primaryColor');
            border-radius: 0 2rpx 2rpx 0;
        }
    }
    
    &.completed {
        opacity: 0.8;
    }
}

.item-badge {
    width: 48rpx;
    height: 48rpx;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10rpx);
    box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.15);
    border: 2rpx solid rgba(255, 255, 255, 0.3);
}

.item-icon {
    font-size: 24rpx;
    filter: drop-shadow(0 1rpx 2rpx rgba(0, 0, 0, 0.3));
}

.item-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8rpx;
    position: relative;
    z-index: 2;
}

.gradient-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.05) 50%, transparent 100%);
    pointer-events: none;
    z-index: 1;
}

.item-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.item-name {
    font-size: 26rpx;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.95);
    text-shadow: 0 1rpx 3rpx rgba(0, 0, 0, 0.3);
}

.item-range {
    font-size: 22rpx;
    color: rgba(255, 255, 255, 0.8);
    text-shadow: 0 1rpx 2rpx rgba(0, 0, 0, 0.3);
}

.item-progress {
    display: flex;
    align-items: center;
    gap: 12rpx;
}

.mini-progress {
    flex: 1;
    height: 4rpx;
    background: v-bind('getThemeStyles().bgTertiary');
    border-radius: 2rpx;
    overflow: hidden;
}

.mini-fill {
    height: 100%;
    border-radius: 2rpx;
    transition: width 1s ease;
}

.item-status {
    min-width: 40rpx;
    text-align: center;
}

.status-current {
    font-size: 18rpx;
    font-weight: 600;
    color: #333;
    background: rgba(255, 255, 255, 0.95);
    padding: 4rpx 12rpx;
    border-radius: 12rpx;
    border: 2rpx solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.15);
}

.status-completed {
    font-size: 20rpx;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 700;
    text-shadow: 0 1rpx 2rpx rgba(0, 0, 0, 0.3);
}

.status-locked {
    font-size: 16rpx;
    color: rgba(255, 255, 255, 0.6);
    text-shadow: 0 1rpx 2rpx rgba(0, 0, 0, 0.3);
}

.level-header {
    display: flex;
    align-items: center;
    gap: 12rpx;
    margin-bottom: 16rpx;
}

.level-number {
    width: 32rpx;
    height: 32rpx;
    border-radius: 50%;
    background: v-bind('getThemeStyles().primaryGradient');
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18rpx;
    font-weight: 700;
    color: white;
    text-shadow: 0 1rpx 2rpx rgba(0, 0, 0, 0.3);
}

.level-badge-small {
    width: 40rpx;
    height: 40rpx;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.15);
}

.level-icon-small {
    font-size: 20rpx;
    filter: drop-shadow(0 1rpx 2rpx rgba(0, 0, 0, 0.3));
}

.level-info {
    margin-bottom: 12rpx;
}

.level-title {
    font-size: 26rpx;
    font-weight: 700;
    color: v-bind('getThemeStyles().textPrimary');
    display: block;
    margin-bottom: 4rpx;
}

.level-requirement {
    font-size: 22rpx;
    color: v-bind('getThemeStyles().textSecondary');
    display: block;
}

.level-indicator {
    position: absolute;
    top: 8rpx;
    right: 8rpx;
}

.current-indicator {
    font-size: 18rpx;
    color: v-bind('getThemeStyles().primaryColor');
    background: rgba(255, 255, 255, 0.9);
    padding: 4rpx 8rpx;
    border-radius: 8rpx;
    font-weight: 600;
    border: 1rpx solid v-bind('getThemeStyles().primaryColor');
}

.level-progress-mini {
    height: 4rpx;
    background: v-bind('getThemeStyles().bgTertiary');
    border-radius: 2rpx;
    overflow: hidden;
    margin-top: 12rpx;
}

.progress-mini-fill {
    height: 100%;
    border-radius: 2rpx;
    transition: width 1s ease;
}

/* 当前等级部分 */
.current-level-section {
    margin-bottom: 32rpx;
    padding-bottom: 24rpx;
    border-bottom: 2rpx solid v-bind('getThemeStyles().borderLight');
}

.current-level-header {
    margin-bottom: 20rpx;
}

.current-level-title {
    font-size: 32rpx;
    font-weight: 700;
    color: v-bind('getThemeStyles().textPrimary');
    display: block;
}

.current-level-card {
    display: flex;
    align-items: center;
    gap: 24rpx;
    padding: 24rpx;
    background: v-bind('getThemeStyles().bgCard');
    border-radius: 20rpx;
    border: 2rpx solid v-bind('getThemeStyles().borderLight');
    box-shadow: v-bind('getThemeStyles().shadowLg');
    position: relative;
    overflow: hidden;
    
    &::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        height: 4rpx;
        background: v-bind('currentLevelInfo.color');
    }
}

.current-level-badge {
    width: 80rpx;
    height: 80rpx;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 24rpx;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10rpx);
    box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.15);
    position: relative;
    overflow: hidden;
    border: 2rpx solid rgba(255, 255, 255, 0.3);
}

.current-level-icon {
    font-size: 40rpx;
    position: relative;
    z-index: 1;
    filter: drop-shadow(0 2rpx 4rpx rgba(0, 0, 0, 0.3));
}

.current-level-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12rpx;
}

.current-level-name {
    font-size: 32rpx;
    font-weight: 700;
    color: v-bind('getThemeStyles().textPrimary');
}

.current-level-score {
    font-size: 26rpx;
    color: v-bind('getThemeStyles().textSecondary');
    font-weight: 500;
}

.current-level-progress {
    display: flex;
    align-items: center;
    gap: 16rpx;
}

.progress-bar {
    flex: 1;
    height: 8rpx;
    background: v-bind('getThemeStyles().bgTertiary');
    border-radius: 4rpx;
    overflow: hidden;
    position: relative;
}

.progress-fill {
    height: 100%;
    border-radius: 4rpx;
    transition: width 1s ease;
    position: relative;
    
    &::after {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
        animation: shimmer 2s infinite;
    }
}

.progress-text {
    font-size: 22rpx;
    font-weight: 600;
    color: v-bind('getThemeStyles().textSecondary');
    min-width: 60rpx;
    text-align: right;
}

.next-level-tip {
    font-size: 24rpx;
    color: v-bind('getThemeStyles().textSecondary');
    padding: 12rpx 16rpx;
    background: v-bind('getThemeStyles().bgTertiary');
    border-radius: 12rpx;
    border-left: 4rpx solid v-bind('getThemeStyles().primaryColor');
}

.next-level-name {
    font-weight: 600;
    color: v-bind('getThemeStyles().primaryColor');
}

.level-header {
    text-align: center;
    margin-bottom: 32rpx;
    padding-bottom: 24rpx;
    border-bottom: 1rpx solid v-bind('getThemeStyles().borderLight');
}

.level-header-title {
    font-size: 32rpx;
    font-weight: 700;
    color: v-bind('getThemeStyles().textPrimary');
    display: block;
    margin-bottom: 8rpx;
}

.level-header-desc {
    font-size: 24rpx;
    color: v-bind('getThemeStyles().textSecondary');
}

.level-description-content {
    display: flex;
    flex-direction: column;
    gap: 20rpx;
}

.level-item {
    display: flex;
    align-items: center;
    padding: 24rpx;
    margin-bottom: 16rpx;
    border-radius: 16rpx;
    border: 2rpx solid transparent;
    transition: all 0.3s ease;
    animation: slideDown 0.3s ease;
    position: relative;
    overflow: hidden;
    box-shadow: 0 8rpx 32rpx rgba(0, 0, 0, 0.12);
    
    &:hover {
        transform: translateX(8rpx);
        box-shadow: 0 12rpx 48rpx rgba(0, 0, 0, 0.2);
    }
}

.level-rank {
    width: 40rpx;
    height: 40rpx;
    border-radius: 50%;
    background: v-bind('getThemeStyles().primaryGradient');
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20rpx;
    font-weight: 700;
    color: white;
    text-shadow: 0 1rpx 2rpx rgba(0, 0, 0, 0.3);
    flex-shrink: 0;
    box-shadow: v-bind('getThemeStyles().buttonBoxShadow');
}

.level-badge {
    width: 56rpx;
    height: 56rpx;
    border-radius: 16rpx;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.15);
    position: relative;
    overflow: hidden;

    &::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: linear-gradient(135deg, rgba(255, 255, 255, 0.2), transparent);
    }
}

.level-icon {
    font-size: 28rpx;
    position: relative;
    z-index: 1;
    filter: drop-shadow(0 1rpx 2rpx rgba(0, 0, 0, 0.3));
}

.level-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8rpx;
}

.level-title {
    font-size: 28rpx;
    font-weight: 700;
    color: v-bind('getThemeStyles().textPrimary');
    margin-bottom: 4rpx;
}

.level-score-requirement {
    font-size: 24rpx;
    color: v-bind('getThemeStyles().textSecondary');
    margin-bottom: 8rpx;
}

.level-progress-bar {
    width: 100%;
    height: 6rpx;
    background: v-bind('getThemeStyles().bgTertiary');
    border-radius: 3rpx;
    overflow: hidden;
    position: relative;
}

.level-progress-fill {
    height: 100%;
    border-radius: 3rpx;
    transition: width 0.8s ease;
    position: relative;
    
    &::after {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
        animation: shimmer 2s infinite;
    }
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

/* 动画定义 */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20rpx);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

@keyframes shine {
    0% {
        left: -100%;
    }
    50% {
        left: 100%;
    }
    100% {
        left: 100%;
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 0.3;
        transform: scale(1);
    }
    50% {
        opacity: 0.6;
        transform: scale(1.1);
    }
}

@keyframes rotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10rpx);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes shine {
    0% {
        left: -100%;
    }
    50% {
        left: 100%;
    }
    100% {
        left: 100%;
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 0.4;
        transform: scale(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(1.05);
    }
}
</style>
